/*
 * IMonaProperties.java
 *
 * Created on 2008/01/03 +0900
 *
 * $Revision: 38 $
 * $Date: 2008-10-11 08:48:45 +0000 (Sat, 11 Oct 2008) $
 */

package org.gikolet.bbs.imona;

import org.gikolet.framework.util.Assert;

/**
 * @author Tetsutaro (latest modification by $Author: tetsutaro.ss $)
 * @version $Revision: 38 $ $Date: 2008-10-11 08:48:45 +0000 (Sat, 11 Oct 2008) $
 */
public class IMonaProperties {
    public static final int IMONA_COMPRESS_LAVEL_P3 = 3;

    public static final int DELETE_URL_NONE = 0;
    public static final int DELETE_URL_U = 1;
    public static final int DELETE_URL_U2 = 2;

    private String cgi2Url;

    private boolean deleteResId;
    private boolean deleteResDate;
    private boolean deleteResMail;
    private boolean deleteName;
    private boolean deleteAA;
    private int deleteUrl;

    private int iMonaCompressLevel;

    // private int gZipCompressLevel;
    // private int zipCompressLevel;
    // private boolean deleteGZipHeader;

    public IMonaProperties() {
	this.deleteResId = false;
	this.deleteResDate = false;
	this.deleteResMail = false;
	this.deleteName = false;
	this.iMonaCompressLevel = IMONA_COMPRESS_LAVEL_P3;
	// this.gZipCompressLevel = 0;
	// this.zipCompressLevel = 0;
	// this.deleteGZipHeader = false;
	this.deleteAA = false;
	this.deleteUrl = DELETE_URL_NONE;
    }

    public IMonaProperties(IMonaProperties iMonaConfig) {
	this.deleteResId = iMonaConfig.deleteResId;
	this.deleteResDate = iMonaConfig.deleteResDate;
	this.deleteResMail = iMonaConfig.deleteResMail;
	this.deleteName = iMonaConfig.deleteName;
	this.iMonaCompressLevel = iMonaConfig.iMonaCompressLevel;
	// this.gZipCompressLevel = iMonaConfig.gZipCompressLevel;
	// this.zipCompressLevel = iMonaConfig.zipCompressLevel;
	// this.deleteGZipHeader = iMonaConfig.deleteGZipHeader;
	this.deleteAA = iMonaConfig.deleteAA;
	this.deleteUrl = iMonaConfig.deleteUrl;
    }

    /**
     * @return the deleteResId
     */
    public boolean isDeleteResId() {
	return this.deleteResId;
    }

    /**
     * @param deleteResId
     *            the deleteResId to set
     */
    public void setDeleteResId(boolean deleteResId) {
	this.deleteResId = deleteResId;
    }

    /**
     * @return the deleteResDate
     */
    public boolean isDeleteResDate() {
	return this.deleteResDate;
    }

    /**
     * @param deleteResDate
     *            the deleteResDate to set
     */
    public void setDeleteResDate(boolean deleteResDate) {
	this.deleteResDate = deleteResDate;
    }

    /**
     * @return the deleteResMail
     */
    public boolean isDeleteResMail() {
	return this.deleteResMail;
    }

    /**
     * @param deleteResMail
     *            the deleteResMail to set
     */
    public void setDeleteResMail(boolean deleteResMail) {
	this.deleteResMail = deleteResMail;
    }

    /**
     * @return the deleteName
     */
    public boolean isDeleteResName() {
	return this.deleteName;
    }

    /**
     * @param deleteName
     *            the deleteName to set
     */
    public void setDeleteName(boolean deleteName) {
	this.deleteName = deleteName;
    }

    /**
     * @return the deleteAA
     */
    public boolean isDeleteResAA() {
	return this.deleteAA;
    }

    /**
     * @param deleteAA
     *            the deleteAA to set
     */
    public void setDeleteAA(boolean deleteAA) {
	this.deleteAA = deleteAA;
    }

    /**
     * @return the deleteUrl
     */
    public int getDeleteResUrl() {
	return this.deleteUrl;
    }

    /**
     * @param deleteUrl
     *            the deleteURL to set
     */
    public void setDeleteUrl(int deleteUrl) {
	switch (deleteUrl) {
	    case DELETE_URL_NONE:
	    case DELETE_URL_U:
	    case DELETE_URL_U2:
		break;

	    default:
		throw new IllegalArgumentException("deleteURL[" + deleteUrl
			+ "] is illegal.");
	}
	this.deleteUrl = deleteUrl;
    }

    /**
     * @return the iMonaCompressLevel
     */
    public int getIMonaCompressLevel() {
	return this.iMonaCompressLevel;
    }

    // /**
    // * @param monaCompressLevel
    // * the iMonaCompressLevel to set
    // */
    // public void setIMonaCompressLevel(int monaCompressLevel) {
    // this.iMonaCompressLevel = monaCompressLevel;
    // }

    /**
     * @return the 2cgiUrl
     */
    public String getCgi2Url() {
	return this.cgi2Url;
    }

    /**
     * @param deleteGZipHeader
     *            the deleteGZipHeader to set
     */
    public void setCgi2Url(String cgi2Url) {
	Assert.isNotNullAndEmpty(cgi2Url);

	this.cgi2Url = cgi2Url;
    }

    public String toString() {
	StringBuffer sb = new StringBuffer();

	if (isDeleteResId()) {
	    sb.append("i");
	}
	if (isDeleteResDate()) {
	    sb.append("t");
	}
	if (isDeleteResMail()) {
	    sb.append("m");
	}
	if (isDeleteResName()) {
	    sb.append("n");
	}
	if (isDeleteResAA()) {
	    sb.append("a");
	}
	if (getDeleteResUrl() == DELETE_URL_U) {
	    sb.append("u");
	} else if (getDeleteResUrl() == DELETE_URL_U2) {
	    sb.append("u2");
	} else if (getIMonaCompressLevel() == IMONA_COMPRESS_LAVEL_P3) {
	    sb.append("p3");
	}

	return sb.toString();
    }
}
